<template>
<div>
  <center>
  <h2>融资申请列表</h2>
  </center>
  <el-form ref="form" :model="form" :inline="true" label-width="80px">
    <el-form-item label="申请类型">
      <el-select v-model="form.jrProductType" placeholder="请选择">
        <el-option label="租房分期" value="1"></el-option>
        <el-option label="收房贷" value="2"></el-option>
        <el-option label="应收租约保理" value="3"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="申请状态">
      <el-select v-model="form.applyState" placeholder="请选择">
        <el-option label="申请中" value="1"></el-option>
        <el-option label="初审通过" value="2"></el-option>
        <el-option label="初审不通过" value="3"></el-option>
        <el-option label="复审通过" value="4"></el-option>
        <el-option label="复审不通过" value="5"></el-option>
      </el-select>
    </el-form-item><br>
    <el-form-item label="查询日期">
        <el-date-picker type="date" placeholder="选择日期" v-model="form.startDate" style="width: 80%;"></el-date-picker>
    </el-form-item>
    <el-form-item>
     到 <el-date-picker type="date" placeholder="选择日期" v-model="form.endDate" style="width: 80%;"></el-date-picker>
    </el-form-item>
    <el-form-item >
      <el-button type="primary" @click="list">查询</el-button>
    </el-form-item>
  </el-form>
  <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      label="申请合同号"
      width="180">
      <template slot-scope="scope">
        {{scope.row.applyOrderNo}}
      </template>
    </el-table-column>
    <el-table-column
      label="贷款信息"
      width="180">
      <template slot-scope="scope">
        {{scope.row.loanMessage}}
      </template>
    </el-table-column>
    <el-table-column
      label="申请类型"
      width="180">
      <template slot-scope="scope">
        <span v-if="scope.row.jrProductType===1">租房分期</span>
        <span v-if="scope.row.jrProductType===2">收房贷</span>
        <span v-if="scope.row.jrProductType===3">应收租约保理</span>
      </template>
    </el-table-column>
    <el-table-column
      label="借款金额"
      width="180">
      <template slot-scope="scope">
        {{scope.row.loanAmount}}元
      </template>
    </el-table-column>
    <el-table-column
      label="借款期限"
      width="180">
      <template slot-scope="scope">
        {{scope.row.monthLimit}}月
      </template>
    </el-table-column>
    <el-table-column
      label="申请日期"
      width="180">
      <template slot-scope="scope">
        {{scope.row.createTime}}
      </template>
    </el-table-column>
    <el-table-column
      label="资金方"
      width="180">
      <template slot-scope="scope">
        {{scope.row.companyName}}
      </template>
    </el-table-column>
    <el-table-column
      label="申请状态"
      width="180">
      <template slot-scope="scope">
        <span v-if="scope.row.applyState===1">申请中</span>
        <span v-if="scope.row.applyState===2">初审通过</span>
        <span v-if="scope.row.applyState===3">初审不通过</span>
        <span v-if="scope.row.applyState===4">复审通过</span>
        <span v-if="scope.row.applyState===5">复审不通过</span>
      </template>
    </el-table-column>
    <el-table-column label="操作" with="160px">
      <template slot-scope="scope">
        <el-button v-if="scope.row.applyState===1" @click.native.prevent="opendialog(scope.row)" type="text" size="small">初审核</el-button>
        <el-button v-if="scope.row.applyState===2" @click.native.prevent="opendialog2(scope.row)" type="text" size="small">复审核</el-button>
        <el-button v-if="scope.row.applyState===4" @click.native.prevent="topay(scope.row)" type="text" size="small">去支付</el-button>
        <el-button @click.native.prevent="deleteRow(scope.row)" type="text" size="small">移除</el-button>
      </template>
    </el-table-column>
  </el-table>
  <pagination
    v-show="total>0"
    :total="total"
    :page.sync="form.pageNum"
    :limit.sync="form.pageSize"
    @pagination="list"
  />
  <el-dialog title="初审核" :visible.sync="dialogVisible" width="50%">
    <div><span style="color: #ffba00;size: 32px">申请主体</span></div><el-divider></el-divider>
    <el-row><el-col :span="12">公司名称：{{hx.loanMessage}}</el-col>
      <el-col :span="12">联系人： {{hx.loanMessage}}</el-col></el-row><br>
    <el-row><el-col :span="12">手机号：18967876789</el-col>
      <el-col :span="12">申请时间： {{hx.createTime}}</el-col></el-row><br>
    <el-row><el-col :span="12">法人：赵小天</el-col>
      <el-col :span="12">法人身份证：13312423652312</el-col></el-row><br>
    <el-row><el-col :span="12">公司地址：大望路万达广场</el-col>
      <el-col :span="12">账户类型：</el-col></el-row><br>
    <el-row><el-col :span="12">账户：</el-col>
      <el-col :span="12">开户行：</el-col></el-row><br>
    <el-row><el-col :span="12">
      法人身份证： <el-image src="https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg" style="width: 150px;height: 80px"></el-image></el-col><el-col :span="12">
    </el-col></el-row><br><span style="color: #ffba00;size: 32px">贷款详细信息</span><el-divider></el-divider>
    <el-row><el-col :span="12">业主姓名：sun</el-col>
      <el-col :span="12">业主身份证号：153482464213421</el-col></el-row><br>
    <el-row><el-col :span="12">业主手机号：14567556435</el-col>
      <el-col :span="12">业主银行卡号：45348123242134</el-col></el-row><br>
    <el-row><el-col :span="12">业主开户行：</el-col>
      <el-col :span="12">租金合计：0.0元</el-col></el-row><br>
    <el-row><el-col :span="12">借款金额：{{ hx.loanAmount }}</el-col>
      <el-col :span="12">贷款利息：0.0元（年化利率11%）</el-col></el-row><br>
    <el-row><el-col :span="12">一次性服务费：{{ hx.loanAmount }}</el-col>
      <el-col :span="12">还款周期：1个月</el-col></el-row><br>
    <el-row><el-col :span="12">租约起始日期：{{ hx.createTime }}</el-col>
      <el-col :span="12">租约结束日期：</el-col></el-row><br>
    <el-row><el-col :span="12">周期还款金额：0.0元</el-col>
      <el-col :span="12">还款账期：{{hx.monthLimit}}</el-col></el-row><br>
    <el-row><el-col :span="12">房产证：</el-col>
      <el-col :span="12"></el-col></el-row><br>
    <el-row><el-col :span="12">租房合同：<el-image src="https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg" style="width: 150px;height: 80px"></el-image></el-col>
      <el-col :span="12"></el-col></el-row><br>
    <el-row><el-col :span="12">业主身份证：</el-col>
      <el-col :span="12"></el-col></el-row><br>
    <el-row><el-col :span="12">业主银行卡：</el-col>
      <el-col :span="12"></el-col></el-row><br>
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="请输入初审密码">
        <el-input v-model="form.password" type="password" style="width: 200px;"></el-input>
      </el-form-item>
      <el-form-item label="操作">
        <el-button @click="checkpass()">校验密码</el-button>
      </el-form-item>
    </el-form>
    <span v-if="passCode===1" style="color: green">密码校验通过,已确认身份</span>
    <span v-if="passCode===2" style="color: red">密码校验失败,未识别身份</span>
    <span slot="footer" class="dialog-footer">
    <el-button type="success" :disabled="passFlag" @click="firstSH()">通过审核</el-button>
    <el-button type="error" :disabled="passFlag" @click="firstnoSH()">不通过审核</el-button>
  </span>
  </el-dialog>
  <el-dialog title="复审核" :visible.sync="dialogVisible2" width="30%">
    <el-form ref="form" :model="form" label-width="120px">
      <div><span style="color: #ffba00;size: 32px">申请主体</span></div><el-divider></el-divider>
      <el-row><el-col :span="12">公司名称：{{hx.loanMessage}}</el-col>
        <el-col :span="12">联系人： {{hx.loanMessage}}</el-col></el-row><br>
      <el-row><el-col :span="12">手机号：18967876789</el-col>
        <el-col :span="12">申请时间： {{hx.createTime}}</el-col></el-row><br>
      <el-row><el-col :span="12">法人：赵小天</el-col>
        <el-col :span="12">法人身份证：13312423652312</el-col></el-row><br>
      <el-row><el-col :span="12">公司地址：大望路万达广场</el-col>
        <el-col :span="12">账户类型：</el-col></el-row><br>
      <el-row><el-col :span="12">账户：</el-col>
        <el-col :span="12">开户行：</el-col></el-row><br>
      <el-row><el-col :span="12">
        法人身份证： <el-image src="https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg" style="width: 150px;height: 80px"></el-image></el-col><el-col :span="12">
      </el-col></el-row><br><span style="color: #ffba00;size: 32px">贷款详细信息</span><el-divider></el-divider>
      <el-row><el-col :span="12">业主姓名：sun</el-col>
        <el-col :span="12">业主身份证号：153482464213421</el-col></el-row><br>
      <el-row><el-col :span="12">业主手机号：14567556435</el-col>
        <el-col :span="12">业主银行卡号：45348123242134</el-col></el-row><br>
      <el-row><el-col :span="12">业主开户行：</el-col>
        <el-col :span="12">租金合计：0.0元</el-col></el-row><br>
      <el-row><el-col :span="12">借款金额：{{ hx.loanAmount }}</el-col>
        <el-col :span="12">贷款利息：0.0元（年化利率11%）</el-col></el-row><br>
      <el-row><el-col :span="12">一次性服务费：{{ hx.loanAmount }}</el-col>
        <el-col :span="12">还款周期：1个月</el-col></el-row><br>
      <el-row><el-col :span="12">租约起始日期：{{ hx.createTime }}</el-col>
        <el-col :span="12">租约结束日期：</el-col></el-row><br>
      <el-row><el-col :span="12">周期还款金额：0.0元</el-col>
        <el-col :span="12">还款账期：{{hx.monthLimit}}</el-col></el-row><br>
      <el-row><el-col :span="12">房产证：</el-col>
        <el-col :span="12"></el-col></el-row><br>
      <el-row><el-col :span="12">租房合同：<el-image src="https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg" style="width: 150px;height: 80px"></el-image></el-col>
        <el-col :span="12"></el-col></el-row><br>
      <el-row><el-col :span="12">业主身份证：</el-col>
        <el-col :span="12"></el-col></el-row><br>
      <el-row><el-col :span="12">业主银行卡：</el-col>
        <el-col :span="12"></el-col></el-row><br>
      <el-form-item label="请输入复审密码">
        <el-input v-model="form.password" type="password"></el-input>
      </el-form-item>
      <el-form-item label="操作">
        <el-button @click="checkpass2()">校验密码</el-button>
      </el-form-item>
    </el-form>
    <span v-if="passCode===1" style="color: green">密码校验通过,已确认身份</span>
    <span v-if="passCode===2" style="color: red">密码校验失败,未识别身份</span>
    <span slot="footer" class="dialog-footer">
    <el-button type="success" :disabled="passFlag" @click="secondSH()">通过审核</el-button>
    <el-button type="error" :disabled="passFlag" @click="secondnoSH()">不通过审核</el-button>
  </span>
  </el-dialog>
</div>
</template>

<script>
import { searchRentInstall,firstSH,secondSH,firstnoSH,secondnoSH} from "@/api/message/installment";
export default {
  name: "rongzi",
  data(){
    return{
      dialogVisible2: false,
      passFlag: true,
      passCode: '',
      form:{
        pageSize:5,
        pageNum:1,
      },
      tableData:[],
      total:0,
      id: '',
      dialogVisible: false,
      pay: {},
      hx: {},
      firstShenhe: {
        id: '',
        applyOrderNo: ''
      },
      secondShenhe: {
        id: '',
        applyOrderNo: ''
      }
    }
  },
  methods:{
    topay(row) {
      this.pay.out_trade_no = row.applyOrderNo
      this.pay.subject = "维数公寓支付"
      this.pay.total_amount = row.loanAmount
      this.pay.body = row.remarks
      this.pay.period = row.monthLimit
      window.open('http://localhost:9205/pay/orders?out_trade_no='+
        row.outOrderNo+'&subject='+this.pay.subject+'&total_amount='+row.loanAmount+
        '&body='+row.remarks+'&period='+row.monthLimit)
    },
    checkpass() {
      const pass = '666666'
      if (this.form.password === pass) {
        this.passCode = 1
        this.passFlag = false
      } else {
        this.passCode = 2
        this.passFlag = true
      }
    },
    checkpass2() {
      const pass = '123456'
      if (this.form.password === pass) {
        this.passCode = 1
        this.passFlag = false
      } else {
        this.passCode = 2
        this.passFlag = true
      }
    },
    opendialog(row) {
      this.dialogVisible = true
      this.firstShenhe.id = row.id
      this.firstShenhe.applyOrderNo = row.applyOrderNo
      this.hx = row
    },
    opendialog2(row) {
      this.dialogVisible2 = true
      this.secondShenhe.id = row.id
      this.secondShenhe.applyOrderNo = row.applyOrderNo
      this.hx = row
    },
    firstSH() {
      firstSH(this.firstShenhe).then(res => {
        if (res.flag) {
          this.$message.success('初审通过')
          this.passCode= ''
          this.passFlag=true
          this.dialogVisible = false
          this.list()
        }else {
          this.$message.error('审核遇到问题，请联系管理员!')
          this.passCode= ''
          this.passFlag=true
          this.dialogVisible = false
          this.list()
        }
      })
    },
    firstnoSH() {
      firstnoSH(this.firstShenhe).then(res => {
        if (res.flag) {
          this.$message.success('初审不通过')
          this.passCode= ''
          this.passFlag=true
          this.dialogVisible = false
          this.list()
        }else {
          this.$message.error('审核遇到问题，请联系管理员!')
          this.passCode= ''
          this.passFlag=true
          this.dialogVisible = false
          this.list()
        }
      })
    },
    secondSH() {
      secondSH(this.secondShenhe).then(res => {
        if (res.flag) {
          this.$message.success('复审通过')
          this.passCode= ''
          this.passFlag=true
          this.dialogVisible2 = false
          this.list()
        }else {
          this.$message.error('审核遇到问题，请联系管理员!')
          this.passCode= ''
          this.passFlag=true
          this.dialogVisible2 = false
          this.list()
        }
      })
    },
    secondnoSH() {
      secondnoSH(this.secondShenhe).then(res => {
        if (res.flag) {
          this.$message.success('复审不通过')
          this.passCode= ''
          this.passFlag=true
          this.dialogVisible2 = false
          this.list()
        }else {
          this.$message.error('审核遇到问题，请联系管理员!')
          this.passCode= ''
          this.passFlag=true
          this.dialogVisible2 = false
          this.list()
        }
      })
    },
    list(){
      searchRentInstall(this.form).then(res=>{
        console.log(res)
          this.tableData=res.list
        this.total=res.total
      })
    },
    uploadRow(id) {
      this.dialogVisible2 = true
      this.id = id
    },
    resetQuery() {
        this.query.name = '',
        this.query.applyState = ''
    }
  },
  created() {
    this.list();
  }
}
</script>

<style scoped>

</style>
